package com.calvin.study.multithread.threadlocal.transmit;

import com.calvin.study.entity.UserEntity;

/**
 * 同一线程中的用户信息
 */
public class UserStorage {

	public static ThreadLocal<UserEntity> USER = new ThreadLocal<UserEntity>() {
		@Override
		protected UserEntity initialValue() {
			UserEntity user = new UserEntity();
			user.setUserId("2920");
			user.setUserName("王弎拾");
			return user;
		}
		
	};

	public static void setUser(UserEntity user) {
		USER.set(user);
	}

	public static UserEntity getUser() {
		return USER.get();
	}

}
